
//
//  IWTitleButton.m
//  ZQKweibo
//
//  Created by laouhn on 15/11/15.
//  Copyright (c) 2015年 宇哥. All rights reserved.
//

#import "IWTitleButton.h"

#define kIwTitleButtonIageW 20
@implementation IWTitleButton

+ (instancetype)titleButton{

    return [[self alloc]init];
}


-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        self.adjustsImageWhenHighlighted = NO;//高亮的时候不要自动调整图标
        self.titleLabel.font = [UIFont boldSystemFontOfSize:19];
        self.imageView.contentMode = UIViewContentModeCenter;//居中
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        //背景
        [self setBackgroundImage:[UIImage imageNamed: @"navigationbar_filter_background_highlighted"] forState:(UIControlStateHighlighted)];
        [self setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    }
    return self;
}

-(CGRect)imageRectForContentRect:(CGRect)contentRect{
    
    CGFloat imageY = 0;
    CGFloat imageW = kIwTitleButtonIageW;
    CGFloat imageX = contentRect.size.width - imageW;
    CGFloat imageH = contentRect.size.height;
    return CGRectMake(imageX, imageY, imageW, imageH);
    
}

-(CGRect)titleRectForContentRect:(CGRect)contentRect{
    
    CGFloat titleY = 0;
    CGFloat titleX = 0;
    CGFloat titleW = contentRect.size.width - kIwTitleButtonIageW;
    CGFloat titleH = contentRect.size.height;
    return CGRectMake(titleX, titleY, titleW, titleH);
    
    
}










@end
